<template>
  <div>
    <el-form ref="form" :model="form" label-width="80px" class="elForm">
      <el-form-item label="类型">
        <el-select
          v-model="form.type"
          placeholder="请选择类型"
          class="region"
        >
          <el-option label="基金" value="基金"></el-option>
          <el-option label="黄金" value="黄金"></el-option>
          <el-option label="定期" value="定期"></el-option>
          <el-option label="活期" value="活期"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="满减底线">
        <el-input placeholder="请输入满减底线" v-model="form.condition"></el-input>
      </el-form-item>
      <el-form-item label="面值">
        <el-input placeholder="请输入面值" v-model="form.value"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期时间"
            v-model="form.createTime"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="过期时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期时间"
            v-model="form.expirationTime"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import {createNamespacedHelpers} from 'vuex';
const {mapActions,mapState} = createNamespacedHelpers('CouponManagementList')
export default {
  data() {
    return {
      form: {
        condition: "22", // 条件
        createTime: "", // 创造时间
        expirationTime: "", // 过期时间
        type: "", // 类型
        value: "1", // 值
      },
    };
  },
  computed:{
    ...mapState([''])
  },
  methods: {
    ...mapActions(['AddCouponManagements']),
    onSubmit() {
      if(this.form.condition&&this.form.createTime&&this.form.expirationTime&&this.form.type&&this.form.value){
        this.AddCouponManagements(this.form)
      }else{
        this.$message.error('请输入完');
      }
    },
  },
};
</script>

<style scoped>
.elForm {
  width: 50%;
}
.region {
  width: 555px;
}
</style>